﻿using System;

namespace Yamfinder.Data
{
    public static class UnixTimeExtensionMethods
    {
        private static DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0);

        public static long ToUnixEpochTime(this DateTime dateTime)
        {
            var difference = dateTime - _unixEpoch;
            return (long)difference.TotalSeconds;
        }

        public static DateTime DateTimeFromEpochTime(this long dateTime)
        {
            return _unixEpoch.AddSeconds(dateTime);
        }
    }
}